__author__ = 'gsoft2-3'
import sys,os
import  xml.dom.minidom

def get_xmlnode(node, name):
    return node.getElementsByTagName(name) if node else []

def get_nodevalue(node, index = 0):
    try:
        return node.childNodes[index].nodeValue if node else ''
    except:
        return ''

def config_values_cehck():
     path = sys.path[0]
     currentpath=""
     if os.path.isdir(path):
         currentpath = path
     elif os.path.isfile(path):
         currentpath = os.path.dirname(path)

     currentFile = currentpath+"/config_values.xml"
     dom = xml.dom.minidom.parse(currentFile)
     root = dom.documentElement
     items = get_xmlnode(root, 'item')
     mylist=[]
     for n in items:
        v = get_nodevalue(n)
        if v != "":
            mylist.append(v)
     return mylist

def config_package_cehck():
     path = sys.path[0]
     currentpath=""
     if os.path.isdir(path):
         currentpath = path
     elif os.path.isfile(path):
         currentpath = os.path.dirname(path)

     currentFile = currentpath+"/config_package.xml"
     dom = xml.dom.minidom.parse(currentFile)
     root = dom.documentElement
     items = get_xmlnode(root, 'item')
     mylist=[]
     for n in items:
        v = get_nodevalue(n)
        if v != "":
            mylist.append(v)
     return mylist